package org.jfk.tbox.net.app;

import java.util.Date;

import org.jfk.core.utils.ByteUtils;
import org.jfk.tbox.net.TboxMsg;

public class TBOX_DeviceStatus {
	static final String appId = "0401";
	
	public class TBOX_DeviceStatusReq extends TboxMsg{
		
		byte deviceCurrentStatus = 0;
		
		public TBOX_DeviceStatusReq(){
			super.appId = TBOX_DeviceStatus.appId;
			super.msgId = 1;
		}
		public void loadData(byte[] data){
			super.loadData(data);
			deviceCurrentStatus = super.appData[0];
		}
		
		public byte[] getAppData(){
			byte[] _vin = ByteUtils.strToASCII(super.vin);
			byte[] b = new byte[1+_vin.length];
			b[0] = deviceCurrentStatus;
			System.arraycopy(_vin, 0, b, 1, _vin.length);
			return b;
		}
		
		public byte[] getResp(){
			TBOX_DeviceStatusResp resp = new TBOX_DeviceStatusResp();
			super.initResp(resp);
			resp.deviceStatusAck = 0;
			resp.sim = "18900001111";
			return resp.toBytes();
		}
		
	}

	public class TBOX_DeviceStatusResp extends TboxMsg{
		byte deviceStatusAck = 0;
		String sim = null;
		public TBOX_DeviceStatusResp(){
			super.appId = TBOX_DeviceStatus.appId;
			super.msgId = 2;
		}
		public void loadData(byte[] data){
			super.loadData(data);
		}
		
		public byte[] getAppData(){
			byte[] _vin = ByteUtils.strToASCII(super.vin);
			byte[] _sim = ByteUtils.strToASCII(this.sim);
			byte[] b = new byte[1+_vin.length+_sim.length];
			
			b[0] = deviceStatusAck;
			int idx = 1;
			System.arraycopy(_vin, 0, b, idx, _vin.length);
			
			idx = idx + _vin.length;
			System.arraycopy(_sim, 0, b, idx, _sim.length);
			
			return b;
		}
		
		public byte[] getResp(){
			return null;
		}
		
	}
}
